Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not pass ownership of the QueryStack in Runtime::block_on_or_unwind #626

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Dec 13, 2024

Builds on top of #624, opened separately as this is this is separate concern that is more likely to be rejected.

This is more of a micro optimization as it reduces the size of Edge by a usize (and it removes one mem::take on a Vec)

Motivation for this change is to reduce the moving of the query stack Vec, that removes a bunch of potential memcopies (at the expense of some more unsafe)

Copy link

netlify bot commented Dec 13, 2024

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 77c96c0
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/675d668203db3500085209d6

Copy link

codspeed-hq bot commented Dec 13, 2024

CodSpeed Performance Report

Merging #626 will not alter performance

Comparing Veykril:veykril/push-koortqxmzkop (77c96c0) with master (5cd2b63)

Summary

✅ 9 untouched benchmarks

@Veykril Veykril force-pushed the veykril/push-koortqxmzkop branch 4 times, most recently from c3873e9 to d1a944e Compare December 13, 2024 12:52
@Veykril Veykril marked this pull request as ready for review December 13, 2024 13:16
@Veykril Veykril force-pushed the veykril/push-koortqxmzkop branch from d1a944e to b3e745b Compare December 13, 2024 14:15
@MichaReiser
Copy link
Contributor

MichaReiser commented Dec 13, 2024

@carljm you should probably take a look at this to prevent that it makes changes that are incompatible with your new fixpoint cycle handling.

@carljm
Copy link
Contributor

carljm commented Dec 13, 2024

I'll have to resolve some merge conflicts, but it looks fine. The cycle-handling code changed here totally disappears in the fixpoint-iteration branch, and the query-stack API changes shouldn't make any difference to that branch.

…wind`

This commit changes `Edge` such that it no longer takes direct ownership of the query stack and instead keeps a lifetime erased mutable slice, an exclusive borrow and as such the ownership model does not change.
The caller now does have to uphold the safety invariant that the query stack borrow is life for the entire computation which is trivially achievable as the caller will block until the computation as done.
@Veykril Veykril force-pushed the veykril/push-koortqxmzkop branch from b3e745b to c57aa8b Compare December 13, 2024 14:54
@carljm
Copy link
Contributor

carljm commented Dec 13, 2024

(To be clear, I haven't carefully reviewed these changes for correctness, and won't have time to do that. But assuming they are reviewed and are good for current Salsa, I'm not worried about their impact on fixpoint iteration. And I don't think other changes should be delayed to wait for fixpoint iteration, since that branch is not ready yet. Resolving merge conflicts isn't a big deal.)

pub(super) struct Edge {
pub(super) blocked_on_id: ThreadId,
pub(super) blocked_on_key: DatabaseKeyIndex,
stack: SendNonNull<[ActiveQuery]>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contemplating whether to use a raw pointer here, or just transmute the lifetimes and store a &'static mut [ActiveQuery] instead. The latter probably simplifies a bit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done that in 77c96c0

@Veykril
Copy link
Member Author

Veykril commented Dec 18, 2024

As discussed, decision on this should either way wait until the fixpoint PR is finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants